/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hhf.worldzones.daos;

import hhf.worldzones.entities.Country;
import hhf.worldzones.entities.Region;
import javax.ejb.Asynchronous;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;

/**
 *
 * @author François
 */
@Stateless
public class RegionDAO extends ZoneDAO<Region> {
	public RegionDAO() {
		super(Region.class);
	}
	
	@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
	@Asynchronous
	public void createRegion(String regionCode, String label, Country country) {
		if (!contains(regionCode)) {
			Region region = new Region();
			region.setCode(regionCode);
			region.setLabel(label);
			persist(region);
		}
	}
}
